package com.cq.hd.member.mapper;

import com.cq.hd.member.api.dto.AdminMemberFeeBillPageDto;
import com.cq.hd.member.api.vo.AdminMemberFeeBillPageVo;
import com.cq.hd.member.po.TbMemberFeeBillPo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 会员套餐开通流水表 Mapper 接口
 * </p>
 *
 * @author mYunYu
 * @since 2023-12-21
 */
@Mapper
public interface TbMemberFeeBillMapper extends BaseMapper<TbMemberFeeBillPo> {

    int updateExpireCancelState(@Param("expireCancelState") Integer expireCancelState, @Param("payState") Integer payState, @Param("businessId") Long businessId);

    List<AdminMemberFeeBillPageVo> listAdminMemberFeeBill(AdminMemberFeeBillPageDto adminMemberFeeBillPageDto);

    int subRemainActiveCount(@Param("id") Long id, @Param("remainActiveCount") Integer remainActiveCount, @Param("now") LocalDateTime now);

    BigDecimal getTotalAmt(@Param("payState") Integer payState);

    // 获取商家已经购买的会员套餐中，max_invite_agent_count 最大值，注意，null 表示不限制，所以他是最大
    Long getMaxInviteAgentCount(@Param("businessId") Long businessId);

    // 获取商家已经购买的会员套餐中，single_active_merchant_count 最大值，注意，null 表示不限制，所以他是最大
    Long getMaxSingleActiveMerchantCount(@Param("businessId") Long businessId);
}
